Repository navigation
fix(id/web): validate UPDATE and CURSOR frame fields in collab handleMessage (#7873) - #8648
Merged
Merged
Conversation
…Message (#7873) UPDATE: drop the frame when steps/clientIDs are not arrays of equal length, and parse all steps with Step.fromJSON before applying any - a parse failure is a frame shape error and drops the frame with the session intact; only apply failures of well-shaped steps keep the desync reconnect path. CURSOR: drop when clientID is not a string/number, head/anchor are not finite numbers, or name is present and not a string/null; idleSecs counts only as a finite number. CURSOR_REMOVE: same clientID validation. Five tests in the collab.test.ts harness style cover each malformed frame (session intact: no close 4001, no reconnect, no phantom cursor) with a valid-frame control after each. collab.test.ts 34/34; tsc clean.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7873 — the UPDATE and CURSOR frame family in
pkgs/id/web/src/collab.tshandleMessagenow validates field shapes at the boundary, in the established style of the #2824 Init hardening (and #7859/#7854):stepsis not an array,clientIDsis not an array, or their lengths differ. All steps are then parsed withStep.fromJSONbefore any is applied — a parse failure is a frame shape error and drops the whole frame. Only an apply failure of well-shaped steps (insidereceiveTransaction/dispatch) keeps the existing desync path (close 4001 + reconnect). Previously one malformed UPDATE (stepsa string, a non-object step) threw inside the applytryand tore the session down.clientIDis not a string/number,head/anchorare not finite numbers, ornameis present and not a string/null.idleSecsis used only when it is a finite number, ignored otherwise. Previously the probe frame[4, 4242, {x:1}, "abc", {evil:1}, "zzz"]was stored verbatim as a phantom cursor feeding NaN positions into the decoration/coords code.clientIDvalidated the same way before it keys the cursor map.Tests
Five tests in the collab.test.ts harness style (
describe("UPDATE/CURSOR frame validation (#7873)")), each malformed frame asserted dropped with the session intact (socket stays OPEN, no reconnect socket after timers, version unmoved), each followed by a valid-frame control that still applies/stores/removes:123,{stepType:"bogus"}) — no 4001, no reconnect, next valid UPDATE applies.PENDING_REMOVAL_MSpath.Verified on the laptop:
bunx vitest run src/collab.test.ts34/34 (29 existing + 5 new); full web suite 764 passed with the single pre-existingsearch-panelaccessibility failure that reproduces identically on clean origin/main (tracked on #8012);bunx tsc --noEmitclean.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.